package data;

import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import modele.Manga;

public class MangaWebConverter {
	
	public void convert(Manga manga, String URL) throws IOException, IllegalArgumentException {
		Document doc = Jsoup.connect(URL).get();
		Element data = doc.getElementById("main");
		
		String title = data.getElementsByTag("h3").first().ownText();
		manga.setNom(title);
		
		String imgPath = data.getElementsByClass("entryPicture").first().absUrl("src");
		URL imgURL = new URL(imgPath);
		manga.image = ImageIO.read(imgURL);
	}
}
